<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease-out;
}

.fade-enter,
.fade-leave-to {
  opacity: 0;
}
/* 通用组件 */
.colla {
  width: 100%;
  margin: 12px 0;
  color: #333333;
  border-bottom: 1px solid #e5e5e5;
  border-left: 1px solid #e5e5e5;
  border-right: 1px solid #e5e5e5;
}
.colla .colla-title {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  height: 38px;
  line-height: 38px;
  padding: 0 12px;
  background-color: #eeeeee;
  border-top: 2px solid #e5e5e5;
}
.colla .icon-jiantouxia {
  display: none;
}
.colla .icon-jiantouxia {
  display: none;
}
.colla .colla-content {
  display: none;
  padding: 8px 8px 18px 8px;
}
.colla .colla-title .title-left {
  display: flex;
  flex-flow: row;
}
.colla .colla-title .title-left .icon {
  font-size: 10px;
  margin-right: 8px;
  padding: 3px;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0.9;
}
.colla .colla-title .title-left .icon:hover {
  color: #409eff;
}
.colla .colla-title .title-right .icon {
  cursor: pointer;
}
.colla .colla-title .title-right .icon:hover {
  color: #409eff;
}
.colla .colla-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: inherit;
}
.colla-show .icon-jiantouxia {
  display: inline;
}
.colla-show .icon-jiantouyou {
  display: none;
}
.colla-show .colla-content {
  display: block;
}
.colla-show .colla-title {
  border-top-color: #409eff;
  background: -webkit-linear-gradient(
    rgb(191, 221, 235),
    #ecf8ff
  ); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(
    rgb(191, 221, 235),
    #ecf8ff
  ); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(
    rgb(191, 221, 235),
    #ecf8ff
  ); /* Firefox 3.6 - 15 */
  background: linear-gradient(rgb(191, 221, 235), #ecf8ff); /* 标准的语法 */
}
</style>
<!--  -->
<template>
  <div
    v-if="!colla.delete"
    :class="{colla:true, 'colla-show':colla.show}"
  >
    <div
      class="colla-title"
      @click.stop="toggel()"
    >
      <div class="title-left">
        <div class="left-icon">
          <i class="icon iconfont icon-jiantouxia"></i>
          <i class="icon iconfont icon-jiantouyou"></i>
        </div>
        <h2 class="left-title">{{title}}</h2>
      </div>
      <div
        class="title-right"
        @click.stop="close()"
      >
        <i class="icon iconfont icon-shanchu"></i>
      </div>
    </div>
    <transition name="fade" >
      <div
        v-if="colla.show"
        class="colla-content"
      >
        <slot></slot>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },
    title: {
      type: String
    }
  },
  data () {
    return {
      colla: {
        show: this.show,
        delete: false
      }
    }
  },
  methods: {
    toggel () {
      this.colla.show = !this.colla.show
    },
    close () {
      this.colla.delete = true
    }
  }
}

</script>
